<?php defined('InShopNC') or exit('Access Invalid!');?>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>优惠促销管理</h3>
      <ul class="tab-base">
        <li><a href="javascript:;" class="current"><span>优惠促销列表</span></a></li>
        <li><a href="index.php?act=discount_promotion&op=dis_promotion_add"><span>添加优惠促销</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <table class="table tb-type2" id="prompt">
    <tbody>
      <tr class="space odd">
        <th class="nobg" colspan="12"><div class="title"><h5><?php echo $lang['nc_prompts'];?></h5><span class="arrow"></span></div></th>
      </tr>
      <tr>
        <td>
          <ul>
            <li>优惠促销管理主要目的是设置个人消息中心的促销活动提醒。所有用户都可以收到促销提醒</li>
            <li>pro_type:优惠促销类型（1拼团列表页，2转盘，3普通商品详情页，4拼团商品详情页，5活动模板）</li>
            <li>pro_major_id:主要的id，不同内容对应不同的索引id，比如，如果pro_type=3,则对应是商品id；如果是列表的话，就不需要填写</li>
            
          </ul>
        </td>
      </tr>
    </tbody>
  </table>
  <form method='post' id="list_form">
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="submit_type" id="submit_type" value="" />
    <input type="hidden" name="class_id" id="class_id">
    <table class="table tb-type2">
      <thead>
        <tr class="thead">
          <th></th>
          <th>促销优惠id</th>
          <th>活动名称</th>
          <th>优惠促销类型</th>
          <th>类型备注</th>
          <th>是否发布</th>
          <th>操作</th>
         
        </tr>
      </thead>
      <tbody>
        <?php if (!empty($output['dis_pro_list']) && is_array($output['dis_pro_list'])) { ?>
        <?php foreach ($output['dis_pro_list'] as $val) { ?>
           <tr class="hover edit">
              <td></td>
              <td class="w48 sort">
                <span nc_type="inline_edit" ajax_branch="class" ><?php echo $val['pro_id'];?></span>
              </td>
              <td class="name">
                <span nc_type="inline_edit" ajax_branch="class" ><?php echo $val['pro_content'];?></span>
                
              </td>
              <td class="name">
                <span nc_type="inline_edit" ajax_branch="class" >
                <?php  if($val['pro_type']==1){echo "拼团列表";}else if($val['pro_type']==2){echo "大转盘";}
                else if($val['pro_type']==3){echo "普通商品详情";}else if($val['pro_type']==4){echo "拼团商品详情";}
                else if($val['pro_type']==5){echo "活动模板";}?>
                </span>
                
              </td>
              <td class="name">
                <span nc_type="inline_edit" ajax_branch="class" ><?php echo $val['pro_major_id'];?></span>
                
              </td>
              <td class="name">
                <span nc_type="inline_edit" ajax_branch="class" ><a  data-id="<?php echo $val['pro_id'];?>" data="<?php echo $val['is_release']; ?>" href="javascript:void(0);" class='is_release'><?php if ( $val['is_release']==1){echo '发布';}else{echo "关闭";};?></a></span>
                
              </td>
              <td class="name">
                <span nc_type="inline_edit"  ><a href="index.php?act=discount_promotion&op=dis_promotion_edt&pro_id=<?php echo $val['pro_id'];?>"> 编辑</a>&nbsp;&nbsp;
                |&nbsp;&nbsp;<a  data-id="<?php echo $val['pro_id'];?>"  href="javascript:void(0);" class='del_dis_pro'>确认删除</a></span>
                
              </td>
              
            </tr>
        <?php } ?>
        <?php }  ?>
        
      </tbody>
     
    </table>
  </form>
</div>
<script type="text/javascript">
/*
 * 发布状态
 */
$('.is_release').click(function(){
	//编号
	var pro_id=$(this).attr("data-id");
	//发布状态
	var is_release=$(this).attr("data");
	change_status(pro_id,is_release);
});

$('.del_dis_pro').click(function(){
	var pro_id=$(this).attr("data-id");
	firm(pro_id);
	
});

//弹出一个询问框，有确定和取消按钮  
function firm(pro_id) {  
    //利用对话框返回的值 （true 或者 false）  
    if (confirm("你确定删除吗？")) {  
    	delete_dispro(pro_id);
    }  
    else {  
        alert("取消操作");  
    }  

} 

/*
 * 删除模板下的所有内容
 */
function delete_dispro(pro_id){
	$.ajax({
	       type: "post",
	       data:{pro_id:pro_id},
	       url: "index.php?act=discount_promotion&op=dis_promotion_del",
	       dataType: "json",
	       async: true,
	       success: function (data) {
		       if(data.status==1){
					alert("删除成功");
					location.reload();

		   		}else{
		   			alert("删除失败");
					location.reload();
			   	} 
		   }

	    });
}

function change_status(pro_id,is_release){
	$.ajax({
	       type: "post",
	       data:{pro_id:pro_id,is_release:is_release},
	       url: "index.php?act=discount_promotion&op=change_status",
	       dataType: "json",
	       async: true,
	       success: function (data) {

		       if(data.status==1){
					alert("状态修改成功");
					location.reload();

		   		}else{
		   			alert("状态修改失败");
					location.reload();
			   	}
		      
		       
		   }

	    });
}


</script>

